Skip to content

Conversation

cslzchen
Copy link
Collaborator

Purpose

TBD

Changes

TBD

QA Notes

TBD

Documentation

TBD

Side Effects

TBD

Ticket

https://openscience.atlassian.net/browse/ENG-8064

cslzchen and others added 17 commits September 18, 2025 11:22
---------

Co-authored-by: John Tordoff <Johnetordoff@users.noreply.github.com>
Co-authored-by: Ostap Zherebetskyi <ozherebetskyi@exoft.net>
Co-authored-by: Bohdan Odintsov <bodintsov@exoft.net>
Co-authored-by: John Tordoff <>
* Fix moderator digest
* Fix unit tests
…ion (#11324)

* Fix issue with user confirmation/merger creating subscription
* Add docstrings
* Add No Login to notification template and add to tests
…tion-refactor-p2-s

* Conflicts have not been resolved in this merge since we want to track
  how we fixed the conflicts due to complexity
  * api/nodes/serializers.py
  * osf/models/user.py
  * tests/test_auth.py
  * tests/test_webtests.py
  * website/templates/node_request_institutional_access_request.html.mako
…plate-with-naming

[ENG-8988] Fix/notification contrib template with naming
Comment on lines 42 to 43
def tearDown(self):
super().tearDown()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed

Comment on lines +749 to +750
with capture_notifications():
fork = node.fork_node(auth_obj)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not we check for captured notifications?

message = f'Failed to send registration bulk upload outcome email due to invalid ' \
f'upload state: [upload={upload.id}, state={upload.state.name}]'
logger.error(message)
sentry.log_message(message)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really not want this in sentry?

res = app.post_json_api(url, payload, auth=user.auth)
assert contributor_added in mock_signal.signals_sent()
assert res.status_code == 201
assert mock_send_grid.call_count == 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we need to verify that emails were not sent

username, fullname, password = 'user_inactive@osf.edu', 'Foo Bar', 'FuAsKeEr'
user = make_user(username, fullname)
user.set_password(password)
with capture_notifications() as mock_signals:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with capture_notifications() as mock_signals:
with capture_notifications():

@@ -467,631 +462,6 @@ def test_wiki_url(self):
assert self._url_to_body(self.wiki.deep_url) == self._url_to_body(self.wiki.url)


@pytest.mark.enable_bookmark_creation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please confirm this to be intended removal

@contextlib.contextmanager
def run_celery_tasks():
yield
celery_teardown_request()

import re, html as html_lib, difflib
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move imports to the start of the file

Comment on lines +475 to +491
def _safe_user_id(u: Any) -> Optional[str]:
"""Normalize user object to stable identifier."""
if u is None:
return None
for attr in ('_id', 'id', 'guids', 'guid', 'pk'):
if hasattr(u, attr):
try:
val = getattr(u, attr)
if hasattr(val, 'first'):
g = val.first()
if g and hasattr(g, '_id'):
return g._id
if isinstance(val, (str, int)):
return str(val)
except Exception:
pass
return f'obj:{id(u)}'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix variable names

Comment on lines +494 to +510
def _safe_obj_id(o: Any) -> Optional[str]:
"""Normalize object to stable identifier."""
if o is None:
return None
for attr in ('_id', 'id', 'guid', 'guids', 'pk'):
if hasattr(o, attr):
try:
val = getattr(o, attr)
if hasattr(val, 'first'):
g = val.first()
if g and hasattr(g, '_id'):
return g._id
if isinstance(val, (str, int)):
return str(val)
except Exception:
pass
return f'obj:{id(o)}'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix variable names

@@ -125,36 +82,6 @@ def add_poster_by_email(conference, message):

utils.upload_attachments(user, node, message.attachments)

download_url = node.web_url_for(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these removals intended?

Copy link
Contributor

@opaduchak opaduchak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several leftover questions:
General opinion on templates:
We need to look through each one, identify redundant variables in event context and remove them. Also we need to verify that all required variables are indeed passed to templates.

This review contains only several topmost templates, therefore there supposedly are many more issues than comments

@@ -15,6 +15,7 @@

@file_updated.connect
def update_file_guid_referent(self, target, event_type, payload, user=None):
event_type = payload['action']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we even need event_type parameter in this case?
I guess we should remove it or at least make it optional

Comment on lines 263 to 264
context['contributors_url'] = f'{self.machineable.target.absolute_url}contributors/'
context['project_settings_url'] = f'{self.machineable.target.absolute_url}settings/'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not needed, they are not present in template

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This template is not used

@@ -7,7 +7,7 @@
</tr>
<tr>
<td style="border-collapse: collapse;">
Hello ${fullname},<br>
Hello ${user_fullname},<br>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

during invocation, fullname is passed instead of user_fullname

Comment on lines 22 to 26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

results are not being passed during invocation

Comment on lines +66 to +76
event_context={
'domain': settings.DOMAIN,
'user_fullname': user.fullname,
'user__id': user._id,
'src__id': src._id,
'src_url': src.url,
'src_title': src.title,
'results': results,
'url': url,
'can_change_preferences': False,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need only src_title here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants